package poker;

import java.util.LinkedList;

/**
 * The board with the 5 cards consisting of Flop, Turn and River.
 * @author guglielmo90
 */
public class Board {
    
    private Deck deck;
    private LinkedList<Card> flop;
    private LinkedList<Card> flopturnriver;
    private Card turn, river;
    
    public Board(){
    
        deck = new Deck();
        flop = new LinkedList<Card>();
        
    }
    
    public Board(Deck deck){
    
        this.deck = deck;
        flop = new LinkedList<Card>();
        turn = null;
        river = null;
        flopturnriver = new LinkedList<Card>();

    }
    
    public void dealFlop(){
    
        deck.getCard();
        
        for(int i = 0; i < 3; i++)
            
            flop.add(deck.getCard());
    
    }
    
    public void dealTurn(){
        
        deck.getCard();
        
        turn = deck.getCard();
    
    }
    
    public void dealRiver(){
        
        deck.getCard();
        
        river = deck.getCard();
        
    }
    
    public LinkedList<Card> getFlop(){
    
        return flop;
    
    }
    
    public Card getTurn(){
    
        return turn;
    
    }
    
    public Card getRiver(){
    
        return river;
    
    }
    
    public void setDeck(Deck deck){
    
        this.deck = deck;
    
    }
    
    public void setCards(){
    
        flopturnriver.add(flop.get(0));
        flopturnriver.add(flop.get(1));
        flopturnriver.add(flop.get(2));
        flopturnriver.add(turn);
        flopturnriver.add(river);
    
    }
    
    public LinkedList<Card> getCards(){
        
        return flopturnriver;
    
    }
    
    @Override
    public String toString(){
    
        if (flop.isEmpty())
            
            return("");
        
        if (turn == null)
            
            return(this.getFlop() + "");
        
        if (river == null)
            
            return(this.getFlop() + " " + this.getTurn());
        
        return (this.getFlop() + " " + this.getTurn() + " " + this.getRiver());
    
    }
    
}
